<script setup>
import { ref } from 'vue'
const guess = ref('')

let rand = parseInt(Math.random()*100)+1
const guess1 = ()=>{
  if(guess.value === rand){
    result.value = '恭喜你猜对了'
  }else if(guess.value > rand){
    result.value = '大了'
  }else{
    result.value = '小了'
  }
}
const result = ref('')
</script>

<template>
<h1>猜数字练习</h1>
  <input type="text" placeholder="请输入一个1-100内的数字" v-model="guess">
  <button @click="guess1">猜一猜</button>
  <p>小提示:{{result}}</p>
</template>

<style scoped>

</style>